import pandas as pd

# 在沙盒环境中使用正确的文件路径
file_path = '/mnt/data/stockdata.sheet'
data = pd.read_excel('stockdata.xlsx')

# 确保其他代码部分正确无误
# ...

# 确保其他代码部分正确无误
# ...

# Ensure '日期' column is in datetime format
data['日期'] = pd.to_datetime(data['日期'])

# Calculate the debt-to-assets ratio for each row
data['资产负债率'] = data['负债合计'] / data['资产总计']

# Get the last year from the '日期' column
last_year = data['日期'].max().year

# Calculate the current debt-to-assets ratio for the last year
current_ratio = data[data['日期'].dt.year == last_year]['资产负债率'].iloc[0]

# Predict the debt-to-assets ratio for the next 10 years
# Assuming a linear increase, which may not be realistic
predicted_ratios = [current_ratio * (1 + i / 10) for i in range(1, 11)]

# Display the predicted ratios
print("预测的未来10年的资产负债率：")
for i, ratio in enumerate(predicted_ratios, start=1):
    print(f"Year {i}: {ratio:.4f}")
